package training.vo;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
 * <ol>
 * 	<li>客戶基本資料檔，對應到 table : customer</li>
 * 	<li>請自行利用eclipse建立 getter and setter</li>
 * 	<li>請overwrite toString(), equals(obj) and hashCode()</li>
 * </ol>
 * @author fatsung
 * @version 1.0
 * @created 2013/03/18 上午 9:58:56
 */
@Entity
@Table(name="customer")
@XmlRootElement(name = "customer")
@XmlType(propOrder = { "id", "name", "password", "salesId"})
public class Customer implements Serializable{
	private static final long serialVersionUID = -3175224006606281609L;
	@Id
	@Column(name="id")//客戶ID
	private String id;
	@Column(name="name")//客戶姓名
	private String name;
	@Column(name="password")
	private String password;
	@Column(name="salesId",updatable = false)
	private String salesId;

	public Customer(){

	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSalesId() {
		return salesId;
	}

	public void setSalesId(String salesId) {
		this.salesId = salesId;
	}

	public void finalize() throws Throwable {

	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Customer [id=");
		builder.append(id);
		builder.append(", name=");
		builder.append(name);
		builder.append(", password=");
		builder.append(password);
		builder.append(", salesId=");
		builder.append(salesId);
		builder.append("]");
		return builder.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Customer other = (Customer) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}